home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / AMOSList / AMOSLIST / text0148.txt < prev    next >
Encoding:
Text File  |  1998-04-01  |  2.5 KB  |  93 lines

  1. I thought I sent this to the list, but apparently not.
  2.  
  3. Does this sound more feasible than all the If Else statements?
  4.  
  5. TSI digitized on 09-Mar-98 14:03:31:
  6. > Hey all,
  7. > I'm a little worried about asking this question seeing as everyone
  8. > has a short fuse on this list, but here goes..
  9.  
  10. Oh, only eric causes that effect :)
  11.  
  12. > I'm too aquainted with extensions, but I'm under the impression
  13. > that they are "add-ins" for amos.. right? Now, I have 2 pc's <it
  14. > take 2 to equal 1 amiga ;) > and I do some coding in Visual Basic
  15. > <if you can call that coding>, one feature I like from VB is the
  16. > SELECT CASE thingy.. I've been looking at alot of my AMOS coding
  17. > and I see alot of "if x = "XXX" then... : if x = "YYY" then..."
  18. > statements and I could save myself alot of coding if AMOS had the
  19. > SELECT CASE statement. Would it be possible for someone to make an
  20. > extension to allow that? For those of you who don't know how SELECT
  21. > CASE works..
  22.  
  23. > IF.. THEN Statements:
  24. > ---
  25. > INPUT X$
  26.  
  27. > IF X$ = "Hello" THEN PRINT "Hello right back, Buddy!!!"
  28. > IF X$ = "Goodbye" THEN PRINT "Ok, seeya!!!"
  29. > ---
  30.  
  31. > SELECT CASE statements:
  32. > ---
  33. > INPUT X$
  34.  
  35. > SELECT CASE X$
  36. >   CASE "hello"
  37. >       PRINT "Hello right back, Buddy!!!"
  38. >   CASE "Goodbye"
  39. >       PRINT "Ok, seeya!!!"
  40. > END SELECT
  41. > ---
  42.  
  43. No extension. BASIC Amos:
  44.  
  45. You can use: ON X GOTO/GOSUB
  46. It's similar to a SWITCH (X$)/CASE in C.
  47.  
  48. --
  49.  
  50. XT$="hg" : Rem It's quicker to define the string when
  51. '          you will use it often.
  52. '          And it's easier to change :)
  53.  
  54.  
  55. _Choice:
  56. Y$=Lower$(Left$(X$,1))
  57. X=Instr(XT$,X$)
  58. On X Goto _Hello,_Goodbye
  59. '                           X= 1 or 2, not 0 or 1
  60. '                           I use GOTO so there's no RETURN to here.
  61. '                           The next RETURN will go back to the
  62. '                           calling function.
  63. '                           This is a fallback statement.
  64. '                           INSTR will set X=0 so you know that
  65. '                           the INSTRing search was unsuccessful.
  66. Print "Command not recognized"
  67. Return
  68.  
  69. _Hello:
  70. Print "Hello right back, Buddy!!!"
  71. Return
  72.  
  73. _Goodbye:
  74. Print "Ok, seeya!!!"
  75. Return
  76.  
  77. --
  78.  
  79.  
  80. Greets,
  81.  - Rand
  82. -- 
  83.   ______                                ________________________ ////
  84.  |   _   \  _____   ___   __ _____      mailto:rand@netwave.net ////
  85.  |  [_}   )(___  \ (   \ |  (  _  \ http://www.netwave.net/members/rand
  86.  |   _   (  / __  \ |   \|  | |_}  )                          ////
  87.  |__| \___)(_______(__|\____(_____/                      \\\\////
  88.  
  89.  
  90. *  <-- Tribble  {{*  <-- Klingon tribble
  91.  
  92.  
  93.